home *** CD-ROM | disk | FTP | other *** search
- /* timer.c - use BIOS time-of-day interrupt */
- #include "stdio.h"
- #include "cminor.h"
- #include "asmtools.h"
-
- long stime ; /* store time-of-day from last call */
- #define TOD_INT 0x1a /* BIOS time-of-day interrupt */
-
- int timer() /* count ticks since last call */
- {
- REGS sreg , dreg ;
- long etime , delta ;
-
- sreg.ax = 0 ; /* get time count */
- swint(TOD_INT,&sreg,&dreg) ; /* get current count - assemble */
- /* 32-bit time-of-day value */
- etime = ( ((long) dreg.cx) << 16 ) + dreg.dx ;
- delta = etime - stime ;
- if( (dreg.ax & 0xff) != 0 ) /* new day since last call ? */
- delta = delta + 0x01800B0L ; /* yes - add 1 day in ticks */
- stime = etime ; /* save time-of-day for next call */
- return( (int) delta ) ; /* return as an integer */
- }